<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<html>
<head>
    <title>添加业务</title>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/bootstrap/css/bootstrap.min.css">
    <script src="${pageContext.request.contextPath}/bootstrap/js/jquery-2.1.0.min.js"></script>
    <script src="${pageContext.request.contextPath}/bootstrap/js/bootstrap.min.js"></script>
    <style>
        body {
            font-family: Arial, sans-serif;
            background-color: #f5f5f5;
            padding: 20px;
        }
        .form-container {
            background-color: #fff;
            padding: 20px;
            border-radius: 5px;
            box-shadow: 0 2px 5px rgba(0,0,0,0.1);
            max-width: 500px;
            margin: 0 auto;
        }
        .form-group {
            margin-bottom: 15px;
        }
        .form-group label {
            display: block;
            margin-bottom: 5px;
            font-weight: bold;
        }
        .form-group input, .form-group select, .form-group textarea {
            width: 100%;
            padding: 8px;
            border: 1px solid #ddd;
            border-radius: 4px;
            box-sizing: border-box;
        }
        .form-group input[type="submit"] {
            background-color: #007bff;
            color: #fff;
            border: none;
            cursor: pointer;
        }
        .form-group input[type="submit"]:hover {
            background-color: #0056b3;
        }
    </style>
</head>
<body>
    <div class="form-container">
        <h2>添加业务</h2>
        <form action="${pageContext.request.contextPath}/shangjia/insert" method="post" enctype="multipart/form-data">
            <div class="form-group">
                <label for="businessName">商家名称</label>
                <input type="text" id="businessName" name="business_name" required>
            </div>
            <div class="form-group">
                <label for="businessDesc">商家描述</label>
                <textarea id="businessDesc" name="business_desc" rows="3" class="form-control"></textarea>
            </div>
            <div class="form-group">
                <label for="businessContact">联系人</label>
                <input type="text" id="businessContact" name="business_contact" required>
            </div>
            <div class="form-group">
                <label for="businessPhone">联系电话</label>
                <input type="text" id="businessPhone" name="business_phone" required>
            </div>
<%--            <div class="form-group">--%>
<%--                <label for="businessImage">商家图片</label>--%>
<%--                <input type="file" id="businessImage" name="image" accept="image/*" multiple>--%>
<%--            </div>--%>
            <div class="form-group">
                <input type="submit" value="提交">
                <button type="button" class="btn btn-default" onclick="window.history.back()">返回</button>
            </div>
        </form>
    </div>

    <script>
        // 图片上传预览功能
        document.getElementById('businessImage').addEventListener('change', function(event) {
            var preview = document.getElementById('image-preview');
            preview.innerHTML = ''; // 清空之前的预览

            var files = event.target.files;
            for (var i = 0; i < files.length; i++) {
                var file = files[i];
                var reader = new FileReader();

                reader.onload = (function(file) {
                    return function(e) {
                        var img = document.createElement('img');
                        img.src = e.target.result;
                        img.style.width = '100px';
                        img.style.height = '100px';
                        img.style.margin = '5px';
                        preview.appendChild(img);
                    };
                })(file);

                reader.readAsDataURL(file);
            }
        });
    </script>
</body>
</html>
